﻿using UnityEngine;

namespace YuoTools
{
    public enum BackgroundAttributeColor
    {
        Red,
        Pink,
        Orange,
        Yellow,
        Green,
        Blue,
        Violet,
        White
    }

    public class BackgroundColorAttribute : PropertyAttribute
    {
        public Color Color;

        public BackgroundColorAttribute(BackgroundAttributeColor color = BackgroundAttributeColor.Yellow)
        {
            this.Color = GetColor(color);
        }
        public BackgroundColorAttribute(float r, float g, float b, float a)
        {
            Color = new Color(r, g, b, a);
        }
        public BackgroundColorAttribute(Color color)
        {
            Color = color;
        }
        private Color GetColor(BackgroundAttributeColor color)
        {
            switch (color)
            {
                case BackgroundAttributeColor.Red:
                    return new Color32(255, 0, 63, 255);
                case BackgroundAttributeColor.Pink:
                    return new Color32(255, 66, 160, 255);
                case BackgroundAttributeColor.Orange:
                    return new Color32(255, 128, 0, 255);
                case BackgroundAttributeColor.Yellow:
                    return new Color32(255, 211, 0, 255);
                case BackgroundAttributeColor.Green:
                    return new Color32(102, 255, 0, 255);
                case BackgroundAttributeColor.Blue:
                    return new Color32(0, 135, 189, 255);
                case BackgroundAttributeColor.Violet:
                    return new Color32(127, 0, 255, 255);
                default:
                    return Color.white;
            }
        }
    }
}
